/* main.c */

#include "app_inc.h"

struct GpioPinStruct 
{
    GPIO_Type *PortDevPtr;
    uint32_t PinIdx;
} gAppGpioLedArray[] = 
{
    {BSP_GPIO_LED1_PORT, BSP_GPIO_LED1_PIN},
    {BSP_GPIO_LED2_PORT, BSP_GPIO_LED2_PIN},
    {BSP_GPIO_LED3_PORT, BSP_GPIO_LED3_PIN},
    {BSP_GPIO_LED4_PORT, BSP_GPIO_LED4_PIN}
};

#define APP_LED_COUNT    (sizeof(gAppGpioLedArray)/sizeof(gAppGpioLedArray[0]))

int main(void)
{
    uint32_t i;;
    
    /* Initialize the board. */
    BSP_InitSystem();
    BSP_InitStdioUART(115200);
    BSP_InitLEDGPIO();
    
    printf("\r\nHello, World\r\n");

    for (i = 0U; i < APP_LED_COUNT; i++)
    {
        /* Set GPIOs' initial voltage level as high. */
        GPIO_SetPinLogic(gAppGpioLedArray[i].PortDevPtr, gAppGpioLedArray[i].PinIdx, true);
        /* Set GPIOs' pin dir as output. */
        GPIO_SetPinDir(gAppGpioLedArray[i].PortDevPtr, gAppGpioLedArray[i].PinIdx, true);
    }

    printf("Press any key to blink the LED ...\r\n");
    
    while (1)
    {
        for (i = 0U; i < APP_LED_COUNT; i++)
        {
            getchar();
            GPIO_TogglePinLogic(gAppGpioLedArray[i].PortDevPtr, gAppGpioLedArray[i].PinIdx);
        }
    }
}

/* EOF. */

